import unittest
import requests
import json
from util.RequestsUtil import RequestUtil

host = "https://api.xdclass.net"
class IndexTestCase(unittest.TestCase):

    def testIndexCategoryList(self):
        """首页分类列表"""
        req =RequestUtil()
        url = host+"/pub/api/v1/web/all_category"
        response = req.requesthandler(url,'get')
        self.assertEqual(response['code'],0,"业务不正常")
        self.assertTrue(len(response['data'])>0,"分类列表为空")


    def testIndexVideoCard(self):
        """首页视频卡片"""
        req = RequestUtil()
        url = host + "/pub/api/v1/web/index_card"
        response = req.requesthandler(url, 'get')
        self.assertEqual(response['code'], 0, "业务不正常")
        self.assertTrue(len(response['data']) > 0, "分类列表为空")

    def testIndexVideoDetail(self):
        "获取视频详情"
        req = RequestUtil()
        url = host + "/pub/api/v1/web/video_detail"
        data = {"video_id":"53"}
        response = req.requesthandler(url, 'get',param=data)
        self.assertEqual(response['code'], 0, "业务不正常")
        self.assertTrue(len(response['data']) > 0, "分类列表为空")




if __name__ == '__main__':
    unittest.main(verbosity=2)

